<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/7/16
 * Time: 14:21
 */

namespace app\admin\logic;

use app\admin\logic\code\ErrorCode;
use app\common\model\LoginLog;

class LoginLogLogic extends BaseLogic
{

    private $loginLogModel;

    public function __construct()
    {
        $this->loginLogModel = new LoginLog();
    }

    public function logList($tempWhere, $nowPage){
        if ($tempWhere['user_name']){
            $where[] = ['user_name', 'like', "%".$tempWhere['user_name']."%"];
        }
        $count = $this->loginLogModel->where($where)->count();
        if ($count <= 0){
            return ajaxArr(ErrorCode::$LISTNULL, '列表为空');
        }

        $list = $this->loginLogModel->where($where)->page($nowPage, self::$pageNum)->order('id desc')->select();
        return ajaxArr(ErrorCode::$SUCCESS, 'success', $list,$count);
    }

}